﻿package mortal.game.view.mount.panel
{
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.menu.*;
    import mortal.game.view.palyer.*;
    import mortal.game.view.wizard.panel.*;

    public class EquipWinItem extends PlayerEquipItem
    {
        private var _notMeetCareerEffect:ScaleBitmap;
        private var _isNotMeet:Boolean;
        private var _data:Object;

        public function EquipWinItem()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            _isShowFreezingEffect = true;
            _isShowLeftTimeEffect = false;
            this.doubleClickEnabled = true;
            isShowLock = true;
            this.isNotMeetCarrer = false;
            this.configEventListener(MouseEvent.DOUBLE_CLICK, this.fastOperate);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            if (this._notMeetCareerEffect)
            {
                this._notMeetCareerEffect.dispose(param1);
                this._notMeetCareerEffect = null;
            }
            EffectManager.glowFilterUnReg(this);
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function updateView() : void
        {
            if (lockedIcon)
            {
                lockedIcon.x = _paddingLeft;
                lockedIcon.y = _paddingTop;
            }
            if (this._notMeetCareerEffect)
            {
                this._notMeetCareerEffect.width = _width - _paddingLeft * 2;
                this._notMeetCareerEffect.height = _height - _paddingTop * 2;
                this._notMeetCareerEffect.x = _paddingLeft;
                this._notMeetCareerEffect.y = _paddingTop;
            }
            return;
        }// end function

        public function set isNotMeetCarrer(param1:Boolean) : void
        {
            this._isNotMeet = param1;
            if (this._isNotMeet)
            {
                if (!this._notMeetCareerEffect)
                {
                    this._notMeetCareerEffect = ResourceConst.getScaleBitmap(ImagesConst.PackDisable);
                    _middleLayer.addChild(this._notMeetCareerEffect);
                    this._notMeetCareerEffect.width = _width - _paddingLeft * 2;
                    this._notMeetCareerEffect.height = _height - _paddingTop * 2;
                    this._notMeetCareerEffect.x = _paddingLeft;
                    this._notMeetCareerEffect.y = _paddingTop;
                }
            }
            if (this._notMeetCareerEffect)
            {
                this._notMeetCareerEffect.visible = this._isNotMeet;
                if (GameController.trade.isViewShow)
                {
                    this._notMeetCareerEffect.visible = false;
                }
            }
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._data = param1;
            if (param1.hasOwnProperty("itemData"))
            {
                if (param1["itemData"] is ItemData)
                {
                    this.itemData = param1["itemData"];
                }
                else if (param1["itemData"] is int)
                {
                    this.itemData = new ItemData(int(param1["itemData"]));
                }
            }
            else
            {
                this.itemData = null;
            }
            return;
        }// end function

        private function fastOperate(event:MouseEvent) : void
        {
            var _loc_2:DataProvider = null;
            if (itemData && itemData.itemInfo)
            {
                if (ItemsUtil.isPetEquip(itemData))
                {
                    if (!PetUtil.isEnoughLevel(itemData))
                    {
                        MsgManager.showRollTipsMsg(Language.getString(35439));
                        return;
                    }
                }
                else if (ItemsUtil.isMountEquip(itemData))
                {
                    if (!MountUtil.isEnoughLevel(_itemData))
                    {
                        return MsgManager.showRollTipsMsg(Language.getString(35440));
                    }
                }
                else if (ItemsUtil.isWizardEquip(itemData))
                {
                    if (!WizardUtil.isEnoughLevelToEquip(_itemData))
                    {
                        return MsgManager.showRollTipsMsg(Language.getString(35441));
                    }
                }
                _loc_2 = ItemMenuConst.getEnabeldAttri(ItemMenuConst.getDataProvider(itemData), itemData);
                ItemMenuConst.opearte(_loc_2.getItemAt(0)["label"], itemData);
            }
            return;
        }// end function

        override public function get toolTipData()
        {
            if (itemData)
            {
                return itemData;
            }
            return super.toolTipData;
        }// end function

    }
}
